<?php

namespace app\util;

/*
 * 微信小程序类
 */

class WxApp
{
    //appid
    const APPID = 'wx825c6d3d37946788';

    //secret
    const SECRET = '3163405810c2aad7c4cc1a78ea220d8c';

    /*
     * 微信小程序获取access_token
     */
    public static function getAccessToken()
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . self::APPID . '&secret=' . self::SECRET;

        $result = Utils::curlSSLGet($url);
        return $result;
    }

    /*
     * 微信小程序获取小程序码
     */
    public static function getwxacode($access_token, $postFields)
    {
        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;

        $result = Utils::curlSSLPost($url, $postFields);
        return $result;
    }

}